package com.springboot.java.design.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: TongRui乀
 * @Date: 2019-12-16 17:14
 * @description： 自定义集合类
 */
public abstract class AbstractObjectCollection {

    protected List<Object> list = new ArrayList<>();

    protected AbstractObjectCollection(List<Object> list){
        this.list = list;
    }

    public void addObject(Object object){
        list.add(object);
    }

    public void delete(Object object){
        list.remove(object);
    }

    public List<Object> getAll(){
        return this.list;
    }

    /**
     *  创建迭代器
     * @return
     */
    public abstract  AbstractIterator iterator();
}
